package com.example.lizhixin.object_three_team.Uitls;

import android.support.v4.app.Fragment;

import com.example.lizhixin.object_three_team.Base.BaseFragment;
import com.example.lizhixin.object_three_team.Fragment.ChoicenessFragment;
import com.example.lizhixin.object_three_team.Fragment.CommunityFragment;
import com.example.lizhixin.object_three_team.Fragment.GameFragment;
import com.example.lizhixin.object_three_team.Fragment.MyFragment;
import com.example.lizhixin.object_three_team.Game_frag.ClassifyFragment;
import com.example.lizhixin.object_three_team.Game_frag.ListFragment;
import com.example.lizhixin.object_three_team.Game_frag.NewFragment;
import com.example.lizhixin.object_three_team.Game_frag.OnlineFragment;
import com.example.lizhixin.object_three_team.Game_frag.RecommendFragment;

public class FragmentFactory {
    private static ChoicenessFragment choicenessFragment;
    private static CommunityFragment communityFragment;
    private static GameFragment gameFragment;
    private static MyFragment myFragment;
    public static  ChoicenessFragment getChoicenessFragment(){
        if (choicenessFragment == null){
            choicenessFragment = new ChoicenessFragment();
        }
        return choicenessFragment;
    }
    public static  CommunityFragment getCommunityFragment(){
        if (communityFragment == null){
            communityFragment = new CommunityFragment();
        }
        return communityFragment;
    }
    public static  GameFragment getGameFragment(){
        if (gameFragment == null){
            gameFragment = new GameFragment();
        }
        return gameFragment;
    }
    public static  MyFragment getMyFragment(){
        if (myFragment == null){
            myFragment = new MyFragment();
        }
        return myFragment;
    }
    public static Fragment getFragment(int index){
        switch (index){
            case 0:
                return getChoicenessFragment();
            case 1:
                return getGameFragment();
            case 2:
                return getCommunityFragment();
            case 3:
                return getMyFragment();
        }
        return null;
    }
    private static ClassifyFragment classifyFragment;
    private static ListFragment listFragment;
    private static NewFragment newFragment;
    private static OnlineFragment onlineFragment;
    private static RecommendFragment recommendFragment;

    public static ClassifyFragment getClassifyFragment(){
        if (classifyFragment == null){
            classifyFragment = new ClassifyFragment();
        }
        return classifyFragment;
    }
    public static NewFragment getNewFragment(){
        if (newFragment == null){
            newFragment = new NewFragment();
        }
        return newFragment;
    }
    public static OnlineFragment getOnlineFragment(){
        if (onlineFragment == null){
            onlineFragment = new OnlineFragment();
        }
        return onlineFragment;
    }
    public  static RecommendFragment getRecommendFragment(){
        if (recommendFragment == null){
            recommendFragment = new RecommendFragment();
        }
        return recommendFragment;
    }
    public static ListFragment  getListFragment(){
        if (listFragment == null){
            listFragment = new ListFragment();
        }
        return listFragment;
    }
    public static  BaseFragment getGameFragment(int index){
        switch (index){
            case  0:
                return getRecommendFragment();
            case 1:
                return getNewFragment();
            case 2:
                return getOnlineFragment();
            case 3:
                return getClassifyFragment();
            case 4:
                return  getListFragment();
        }
        return null;
    }
}
